import { defineStore } from 'pinia';
import { ref } from 'vue';

export const userCounterStore = defineStore(
  'counter',
  () => {
    const count = ref(0);

    const user = ref([
      {
        name: 'John Doe',
        age: 30,
        email: 'johndoe@example.com',
      },
      {
        name: 'sb',
        age: 30,
        email: 'johndoe@example.com',
      },
      {
        name: 'cxk',
        age: 30,
        email: 'johndoe@example.com',
      },
    ]);
    const Add = () => {
      count.value++;
    };

    const Sub = () => {
      count.value--;
    };

    const Double = () => {
      return count.value * 2;
    };

    const sbUser = () => {
      user.value.splice(1, 1);
    };

    return { count, Add, Sub, Double, user, sbUser };
  },
  { persist: true },
);
